package com.metal.gear.certification.entity.dto.permission;

import com.metal.gear.certification.entity.po.SysPermission;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Schema(name ="菜单和按钮权限创建和编辑实体")
public class PermissionSaveAndEditDto {
    @Schema(name ="id")
    private String id;
    @Schema(name ="父级菜单id")
    private String parentId;
    @Schema(name ="（菜单/按钮）名称")
    private String name;
    @Schema(name ="是否路由，是路由菜单必有url，否则无url")
    private Boolean isRoute;
    @Schema(name ="路由地址")
    private String url;
    @Schema(name ="重定向路径，用于系统之外页面跳转，redirect存在则isRoute和url均为null")
    private String redirect;
    @Schema(name ="权限类型：0（一级菜单）,1（二级菜单）,2（按钮）")
    private Integer menuType;
    @Schema(name ="排序码")
    private Double sortNo;


    public static SysPermission TranslateTo(PermissionSaveAndEditDto dto){
        SysPermission po = new SysPermission();
        BeanUtils.copyProperties(dto,po);
        po.setRoute(dto.getIsRoute());
        return po;
    }


}
